import QtInput from './input';
import QtCard from './card';
import QtDate from './date';
import QtList from './list';
import QtForm from './form';
import QtSelect from './select';
import QtTable from './table';
import QtButton from './button';
import QtButtonGroup from './button-group';
import QtCommonPicker from './common-picker';
import QtSwitch from './switch';

function install(Vue) {
  const compoments = [
    QtInput,
    QtCard,
    QtDate,
    QtList,
    QtForm,
    QtSelect,
    QtTable,
    QtButton,
    QtButtonGroup,
    QtCommonPicker,
    QtSwitch,
  ];

  compoments.forEach((item) => {
    if (item.install) {
      Vue.use(item);
    } else if (item.name) {
      Vue.component(item.name, item);
    }
  });
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue);
}

export {
  install,
  QtInput,
  QtCard,
  QtDate,
  QtList,
  QtForm,
  QtSelect,
  QtTable,
  QtButton,
  QtButtonGroup,
  QtCommonPicker,
  QtSwitch,
};

export default {
  install,
};
